(function($, doc, chat) {

	var settings = app.getSettings();
	var state = app.getState();
	var uid = state.user_id;

	//console.log(uid);
	//localStorage.removeItem('mainlist' + uid);
	/*window.addEventListener('refreshList', function(e) {
			//console.log(JSON.stringify(e));
		chat.renderlist();
	});*/
	
	$.plusReady(function() {
		mui.init({
			gestureConfig: {
				tap: true, //默认为true
				doubletap: true, //默认为false
				longtap: true, //默认为false
				swipe: true, //默认为true
				drag: true, //默认为true
				hold: true, //默认为false，不监听
				release: true //默认为false，不监听
			},
			/*preloadPages: [{
				url: 'contact.html',
				id: 'contact.html'
			}, {
				url: 'find.html',
				id: 'find.html'
			}, {
				url: 'me.html',
				id: 'me.html'
			}]*/

		});
		window.addEventListener('refreshList', function(e) {
			//console.log(JSON.stringify(e));
			chat.renderlist();
		});
		window.addEventListener('passFriends', function(event) {
			chat.renderlist();
			doc.getElementById('hasmsg1').style.display = 'none';
			doc.getElementById('hasmsg2').style.display = 'none';
		});
		window.addEventListener('hasFriends', function(event) {
			doc.getElementById('hasmsg1').style.display = '';
			doc.getElementById('hasmsg2').style.display = '';
		});
		//var chatdata = chat.get();
		chat.updateList();
		chat.renderlist();
		setTimeout(function(){chat.renderlist();},2000);
		var mainid = localStorage.getItem('mainpage');
		
		var mainWin = plus.webview.getWebviewById(mainid);
		//mui.fire(mainWin, 'login', null);
		doc.addEventListener('swipeleft', function(event) {
			var angle = event.detail.angle;
			angle = Math.abs(angle);
			if(angle > 165 && angle < 195) {
				mui.fire(mainWin, 'swipe_event', {
					target: 'contact.html'
				});
			}

		});
		/*
		doc.addEventListener('swiperight', function(event) {
			if(Math.abs(event.detail.angle) < 30) {
				mui.fire(mainWin, 'swipe_event', {
					target: 'me.html'
				});
			}
		});*/
	});

}(mui, document, chat));